#include <stdio.h>
#include "personal.h"

// 根据乘客数量获取密度等级
DensityLevel get_density_level(int passenger_count) {
    if (passenger_count == 0) {
        return DENSITY_EMPTY;
    } else if (passenger_count <= 40) {
        return DENSITY_VERY_LOW;
    } else if (passenger_count <= 80) {
        return DENSITY_LOW;
    } else if (passenger_count <= 120) {
        return DENSITY_MODERATE;
    } else if (passenger_count <= 160) {
        return DENSITY_HIGH;
    } else if (passenger_count <= 200) {
        return DENSITY_VERY_HIGH;
    } else {
        return DENSITY_EXTREME;
    }
}

// 将密度等级转换为可读字符串
const char* density_level_to_string(DensityLevel level) {
    switch (level) {
        case DENSITY_EMPTY:     return "无人";
        case DENSITY_VERY_LOW:  return "极低密度";
        case DENSITY_LOW:       return "低密度";
        case DENSITY_MODERATE:  return "中等密度";
        case DENSITY_HIGH:      return "高密度";
        case DENSITY_VERY_HIGH: return "极高密度";
        case DENSITY_EXTREME:   return "极端密度";
        default:               return "未知密度";
    }
}

// 测试函数
int main() {
    int test_counts[] = {0, 5, 40, 41, 80, 81, 100, 120, 121, 140, 160, 161, 180, 200, 201, 250};
    int num_tests = sizeof(test_counts) / sizeof(test_counts[0]);
    
    printf("乘客流量 | 密度等级 | 描述\n");
    printf("--------|---------|----------\n");
    
    for (int i = 0; i < num_tests; i++) {
        int count = test_counts[i];
        DensityLevel level = get_density_level(count);
        const char* desc = density_level_to_string(level);
        
        printf("%-7d | %-7d | %s\n", count, level, desc);
    }
    
    return 0;
}